package net.xinqushi.service.impl;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import net.xinqushi.dao.UserDAO;
import net.xinqushi.model.User;
import net.xinqushi.service.UserService;
@Component(value="service")
@Scope(value="singleton")
public class UserServiceImpl implements UserService {
	
	UserDAO dao;
	
/*	public UserServiceImpl(UserDAO dao) {
		super();
		this.dao = dao;
	} //通过构造函数注入一个 dao
*/
	public UserDAO getDao() {
		return dao;
	}
	@Resource(name="sqlDAO")
	public void setDao(UserDAO dao) {//注入方法
		this.dao = dao;
	}
	@Override
	public void add(User user) {
		// TODO Auto-generated method stub
		System.out.println("当前对象的id:"+this);
		dao.save(user);
	}
	@Override
	public boolean checkExists(User user) {
		// TODO Auto-generated method stub
		return dao.isExists(user);
	}
	@Override
	public User get(User user) {
		// TODO Auto-generated method stub
		return null;
	}

}
